using System;
using System.Collections.Generic;
using System.Data.Entity.Infrastructure.Interception;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using log4net;

namespace Comteck.Ktt.Services.Infrastructure {
  /// <summary>
  /// 
  /// </summary>
  public class EFLoggerForDebug : IDbCommandInterceptor {
    public static ILog Logger = LogManager.GetLogger(typeof(EFLoggerForDebug));

    public void NonQueryExecuting(System.Data.Common.DbCommand command, DbCommandInterceptionContext<int> interceptionContext) {
      Logger.Info(command.CommandText);
      //Debug.WriteLine(command.CommandText);
    }

    public void NonQueryExecuted(System.Data.Common.DbCommand command, DbCommandInterceptionContext<int> interceptionContext) {
    }

    public void ReaderExecuting(System.Data.Common.DbCommand command, DbCommandInterceptionContext<System.Data.Common.DbDataReader> interceptionContext) {
      Logger.Info(command.CommandText);
      //Debug.WriteLine(command.CommandText);
    }

    public void ReaderExecuted(System.Data.Common.DbCommand command, DbCommandInterceptionContext<System.Data.Common.DbDataReader> interceptionContext) {
    }

    public void ScalarExecuting(System.Data.Common.DbCommand command, DbCommandInterceptionContext<object> interceptionContext) {
      Logger.Info(command.CommandText);
      //Debug.WriteLine(command.CommandText);
    }

    public void ScalarExecuted(System.Data.Common.DbCommand command, DbCommandInterceptionContext<object> interceptionContext) {
    }
  }
}
